package com.ssm.juc.volatile100;

public class VolatileAddTest {
    static int number = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(VolatileAddTest::add100000);
        Thread thread2 = new Thread(VolatileAddTest::add100000);
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println("----> number = " + number);
    }

    private static synchronized void add100000() {
        for (int i = 0; i < 100000; i++) {
            number++;
        }
    }
}
